<?php

namespace common\models\datas;

use Yii;

/**
 * This is the model class for table "{{%message}}".
 *
 * @property integer $id
 * @property integer $site_id
 * @property integer $sender_id
 * @property integer $receiver_id
 * @property string $content
 * @property integer $created_at
 * @property integer $is_all
 * @property integer $admin_id
 * @property integer $log_id
 * @property integer $type_id
 */
class Message extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%message}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['site_id', 'sender_id', 'receiver_id', 'created_at', 'is_all', 'admin_id', 'log_id', 'type_id','status'], 'integer'],
            [['content','send_group'], 'required'],
            [['content'], 'string', 'max' => 255],
            [['send_group'], 'string', 'max' => 50]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', '自动编号'),
            'site_id' => Yii::t('app', '所属广场'),
            'sender_id' => Yii::t('app', '发送者'),
            'receiver_id' => Yii::t('app', 'Receiver ID'),
            'content' => Yii::t('app', '发送内容'),
            'created_at' => Yii::t('app', '发送时间'),
            'is_all' => Yii::t('app', '是否全部发送'),
            'admin_id' => Yii::t('app', '操作管理员'),
            'log_id' => Yii::t('app', '日志编号'),
            'type_id' => Yii::t('app', '消息类型'),
            'status' => Yii::t('app', '状态0未读1已读2删除'),
            'send_group' => Yii::t('app', '发送对象'),
        ];
    }

    public function afterSave($insert, $changedAttributes)
    {
        parent::afterSave($insert, $changedAttributes);
    }
}
